/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.dialogs;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.*;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author max
 */
public class StartSim extends JDialog implements ActionListener, KeyListener{
    
    JLabel l1 = new JLabel("Dauer: ");
    JTextField t1 = new JTextField(5);
    JLabel l2 = new JLabel("s  Zeitinkrement: ");
    JTextField t2 = new JTextField(5);
    JLabel l3 = new JLabel("s");
    JPanel pan1 = new JPanel();
    JPanel pan2 = new JPanel();
    JButton but1 = new JButton("OK");
    
    
    double t=0,dt=0;
    
    public StartSim(JFrame parent){
    super(parent, "Parameter", true);
        
      t1.setHorizontalAlignment(JTextField.RIGHT);
    t2.setHorizontalAlignment(JTextField.RIGHT);
         t1.setText("150");
    t2.setText("0.01");
   
//    this.setLocationRelativeTo(parent.);
    this.setLocation(parent.getLocation().x+parent.getWidth()/2-130,parent.getLocation().y+parent.getHeight()/2-50);
    this.setLayout(new BorderLayout());
    
    this.add(pan1, BorderLayout.CENTER);
    this.add(pan2,BorderLayout.SOUTH);
    but1.addKeyListener(this);
    pan1.setLayout(new FlowLayout(FlowLayout.CENTER));
    pan1.add(l1);
    pan1.add(t1);
    pan1.add(l2);
    pan1.add(t2);
    pan1.add(l3);
    pan2.add(but1);
    but1.addActionListener(this);
    this.pack();
    this.setVisible(true);
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  
    
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        
        t = Double.parseDouble(t1.getText());
        dt = Double.parseDouble(t2.getText());
        super.dispose();
        
    }
    
    public double gett(){return t;}
    public double getdt(){return dt;}

    @Override
    public void keyTyped(KeyEvent e) {
     
    }

    @Override
    public void keyPressed(KeyEvent e) {

       if(e.getKeyCode() == KeyEvent.VK_ENTER) actionPerformed(null);
    }

    @Override
    public void keyReleased(KeyEvent e) {
     
    }
    
}
